﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectonString = "server=.;database=Test;uid=sa;pwd=12345";
            SqlConnection sqlConnection = new SqlConnection(connectonString);
            sqlConnection.Open();

            var sqlCommandSting = "select * from Username";
            SqlCommand sqlCommand = new SqlCommand(sqlCommandSting, sqlConnection);

            var sqlDataReader = sqlCommand.ExecuteReader();

            while(sqlDataReader.Read()){
                Console.WriteLine("编号：" + sqlDataReader["id"] + "用户名：" + sqlDataReader["name"] + "性别：" + sqlDataReader["sex"]);

            }
            sqlConnection.Close();
            Console.Read();
        }
    }
}
